using System;

namespace Slf.Samples.DefaultLogger
{
  class Program
  {
    static void Main(string[] args)
    {
      //configure LoggerService to log to the console through the ConsoleLogger
      LoggerService.SetLogger(new ConsoleLogger());
      
      //create an instance of class FooBar and let it log.
      //FooBar does not know that it logs to the Console...
      FooBar fooBar = new FooBar();
      fooBar.LogHelloWorld();

      
      //replace the default logger (using a delegate logger this time)
      var logger = new DelegateLogger(li => Console.Out.WriteLine("Logging through DelegateLogger: " + li.Message));
      LoggerService.SetLogger(logger);

      //let the FooBar class log again
      fooBar.LogHelloWorld();

      Console.ReadLine();
    }
  }



  /// <summary>
  /// This class does not know anything about the current
  /// configuration of <see cref="LoggerService"/>. It just
  /// logs through it...
  /// </summary>
  public class FooBar
  {
    public void LogHelloWorld()
    {
      //get the logger...
      ILogger logger = LoggerService.GetLogger();

      //...and log an informational message
      logger.Info("hello world :)");
    }
  }
}